package com.boot.persistence.condition;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;

/**
 * @author 霜寒 <1621856595@qq.com>
 * @description 分页条件
 * @date 2020/6/4 0:06
 **/
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode
@ApiModel(value = "分页条件对象")
public class PageCondition {

    @Min(1)
    @ApiModelProperty(value = "当前页", name = "pageNum")
    private Integer pageNum;
    @Max(500)
    @ApiModelProperty(value = "每页记录数", name = "pageSize")
    private Integer pageSize;
    @ApiModelProperty(value = "不分页", name = "noPage")
    private Boolean noPage;

    public boolean isUseful() {
        if (noPage != null && noPage) {
            return false;
        } else {
            return pageNum != null && pageSize != null;
        }
    }
}
